var parseCode = {
    "0x0000": "成功",
    "0x0001": "错误的消息内容",
    "0x0002": "错误的参数",
    "0x0003": "IP地址不可达",
    "0x0004": "未初始化",
    "0x0005": "证书未加载",
    "0x0006": "服务不支持",
    "0x0007": "错误的域",
    "0x0008": "错误的类型",
    "0x0009": "错误的订阅类型",
    "0x0100": "其他错误",
    "0x0110": "消息发送超时",
    "0x0111": "消息处理异常",
    "0x0200": "SOCOKE错误",
    "0x0201": "连接为空",
    "0x0202": "连接超时",
    "0x0203": "连接中断",
    "0x0300": "Json错误",
    "0xFFFF": "未知错误",
    "0x7000": "未指定错误",
    "0x7001": "错误的客户端ID",
    "0x7002": "客户端未注册",
    "0x7003": "服务器拒绝",
    "0x7004": "用户数限制",
    "0x7005": "客户端已注册",
    "0x7006": "无效的对方ID",
    "0x7007": "数据内容过大",
    "0x7008": "错误的method字段",
    "0x7009": "call_id字段为空",
    "0x700A": "新证书和原证书不匹配",
    "0x8000": "证书内容错误",
    "0x8001": "无效的证书编号",
    "0x8002": "证书连接地址格式错误",
    "0x8003": "连接地址无权限",
    "0x8004": "订阅类型格式错误",
    "0x8005": "订阅类型无权限",
    "0x8006": "通知类型格式错误",
    "0x8007": "通知类型无权限",
    "0x8008": "证书有效期格式错误",
    "0x8009": "证书不在有效期",
    "0x800A": "发送类型格式错误",
    "0x800B": "发送类型无权限"
}
var reqDataTypeName = {
    "@clw_dynamic_cbais@":"浙江AIS数据消息总线协议",
    "@gskk_ex@wz.zj":"高速卡口数据分拣消息总线协议ex",
    "@gskk_en@wz.zj":"高速卡口数据分拣消息总线协议en",
    "@lkxx_yys@":"高速路况",
    "@Traffic_survey@":"交调实时数据消息总线协议",
    "@online_cnt@":"高速流量数据统计",
    "330000@gps@809":"跨域车辆-部到省（外网）",
    "5*@gps@809":"省内两客一危-省到部（外网）",
    "50626@gps@809":"省内两客一危-省到部（外网）",
    "50627@gps@809":"省内两客一危-省到部（外网）",
    "@taxi_data@":"出租车数据消息总线协议",
    "@clw_dynamic_cbais@sh0": "上海AIS数据消息总线协议",
    "gskk_enex_stats_resp": "按天查询进出站数量",
    "gskk_enex_stats_area_resp": "按区域查询进出站数量",
    "gskk_enex_stats_station_resp": "按站点查询进出站数量",
    "gskk_weight_stats_resp": "按天查询进出站重量",
    "gskk_weight_stats_area_resp": "按区域查询进出站重量",
    "gskk_weight_stats_station_resp": "按站点查询进出站重量",
    "tl_cz_name_resp": "根据车站简拼查询车站站名",
    "tl_cz_province_resp": "按省名查询省内车站",
    "tl_cz_time_resp": "按车站、日期查询车站时刻信息",
    "tl_lc_time_resp": "列车时刻表信息",
    "tl_lc_sj_resp": "根据站名、日期、车次查询列车到发实际",
    "tl_lc_df_resp": "根据站名、日期、车次查询列车到发计划",
    "tl_get_zm_resp": "获取站码对照表信息",
    "tl_lclx_xx_resp": "列车类型对照表信息",
    "tl_cz_sxk_resp": "根据车次、日期、车站获取上下车人数（实际）",
    "tl_cz_sxk_ys_resp": "根据车次、日期、车站获取上下车人数（预售）",
    "hlzh_hbdt_resp": "查询机场动态",
    "adsb_aircraft_resp": "查询飞机动态",
    "adsb_aircraft_list_resp": "查询飞机动态列表",
    "fcz_wlhbskb_resp": "查询航班信息",
    "fcz_jcll_resp": "查询机场进出港流量信息",
    "taxi_list_resp": "查询出租车信息列表",
    "http://120.55.85.1:8066/cmb/gskk_stats_data":"高速当日流量",
    "http://120.55.85.1:8066/cmb/gskk_stats_manual":"高速流量录入",
    "http://120.55.85.1:8066/cmb/gskk_llqs_data":"高速实时流量趋势",
    "http://120.55.85.1:8066/cmb/zjqr_gsll_data":"高速流量最近7日",
    "http://120.55.85.1:8066/cmb/drgsll_sspm":"高速当日收费站流量实时排名",
    "http://120.55.85.1:8066/cmb/gsxx_data":"高速区域当日流量",
    "http://120.55.85.1:8066/cmb/sjjckll":"高速省际进出当日客流",
    "http://120.55.85.1:8066/cmb/gsll_db":"高速流量当日和昨日对比",
    "http://120.55.85.1:8066/cmb/gsll_db_jjr":"高速流量节假日对比",
    "http://120.55.85.1:8066/cmb/gsll_stats_more":"高速卡口数据统计",
    "http://120.55.85.1:8066/cmb/gstdhz":"高速路况信息",
    "http://120.55.85.1:8066/cmb/airline_list":"航线信息",
    "http://120.55.85.1:8066/cmb/aircraft_list":"飞机动态列表查询",
    "http://120.55.85.1:8066/cmb/aircraft_polymerize_list":"飞机聚合查询",
    "http://120.55.85.1:8066/cmb/airport_status_list":"机场动态",
    "http://120.55.85.1:8066/cmb/airport_last_7days":"机场最近7日趋势",
    "http://120.55.85.1:8066/cmb/airport_db":"机场客流当日和昨日对比",
    "http://120.55.85.1:8066/cmb/airport_db_jjr":"机场节假日客流对比",
    "http://120.55.85.1:8066/cmb/tlkl_station_top":"铁路车站动态",
    "http://120.55.85.1:8066/cmb/tlkl_sxk":"铁路客流信息",
    "http://120.55.85.1:8066/cmb/tlkl_last_7days":"铁路过去7日客流趋势",
    "http://120.55.85.1:8066/cmb/tlkl_station_last_7days":"铁路车站过去7日客流趋势",
    "http://120.55.85.1:8066/cmb/tlkl_next_7days":"铁路未来7日客流趋势",
    "http://120.55.85.1:8066/cmb/tlkl_next_12hours":"铁路未来12小时客流趋势",
    "http://120.55.85.1:8066/cmb/tlkl_db":"铁路客流当日和昨日对比",
    "http://120.55.85.1:8066/cmb/tlkl_db_jjr":"铁路客流节假日对比",
    "http://120.55.85.1:8066/cmb/lkyw_online_total":"两客一危在线车辆统计",
    "http://120.55.85.1:8066/cmb/lkyw_polymerize_list":"两客一危聚合查询",
    "http://120.55.85.1:8066/cmb/kyz_data":"客运站信息",
    "http://120.55.85.1:8066/cmb/taxi_list":"出租车列表查询",
    "http://120.55.85.1:8066/cmb/taxi_polymerize_list":"出租车聚合查询",
    "http://120.55.85.1:8066/cmb/get_jjr":"节假日查询",
    "http://120.55.85.1:8066/cmb/ais_list":"船舶动态列表查询",
    "http://120.55.85.1:8066/cmb/ais_polymerize_list":"船舶聚合查询",
    "http://120.55.85.1:8066/cmb/map_tmc_info":"TMC信息查询",
    "http://120.55.85.1:8066/cmb/map_tmc_status":"TMC状态查询",
};

var logParse = {
    "REGISTER":"注册",
    "RIGISTER":"注册",
    "START":"连接打开",
    "client_register":"客户端注册",
    "DISCONNECT":"断开",
    "ADD_SUBSCRIBE":"新增订阅",
    "DEBUG":"调试",
    "ADD_ROUTE":"添加路由",
    "TIMEOUT":"超时",
    "DELETE_ROUTE":"删除路由",
    "DEL_SUBSCRIBE":"删除订阅",
    "@ws_find@":"服务查找（@ws_find@）",
    "@cmb_find@":"服务查找（@cmb_find@）",
    "ws_find_resp":"服务查找响应（ws_find_resp）",
    "cmb_find_resp":"服务查找响应（cmb_find_resp）",
    "ws_log_req":"日志查询（ws_log_req）",
    "cmb_log_req":"日志查询（cmb_log_req）",
    "cmb_log_resp":"日志查询响应（cmb_log_resp）",
    "ws_log_resp":"日志查询响应（ws_log_resp）",
}

var cpuParse = {
    "0":"时间",
    "1":"当前连接的消息总线服务GUID",
    "2":"全局cpu占用率百分比",
    "3":"全局内存占用率百分比",
    "4":"全局磁盘占用率百分比",
    "5":"服务cpu占用率百分比",
}

var subsInfo = "@gskk_en@wz.zj;@gskk_ex@wz.zj;@lkxx_yys@;@clw_dynamic_cbais@;@Traffic_survey@;@gskk_en@zj;@gskk_ex@zj;@taxi_data@;@clw_dynamic_cbais@sh"; //订阅内容
var gps30Info = "330000@gps@809"; //订阅内容
var gps50Info = "5[\\d]*@gps@809"; //订阅内容

var respType = ["gskk_enex_stats_resp", "gskk_enex_stats_area_resp", "gskk_enex_stats_station_resp",
    "gskk_weight_stats_resp", "gskk_weight_stats_area_resp", "gskk_weight_stats_station_resp",
    // "tl_cz_name_resp", "tl_cz_province_resp", "tl_cz_time_resp", "tl_lc_time_resp", "tl_lc_sj_resp",
    // "tl_lc_df_resp", "tl_get_zm_resp", "tl_lclx_xx_resp", "tl_cz_sxk_resp", "tl_cz_sxk_ys_resp",
    "hlzh_hbdt_resp", "adsb_aircraft_resp", "adsb_aircraft_list_resp", "fcz_wlhbskb_resp",
    "fcz_jcll_resp","taxi_list_resp"
] //响应请求类型
 //请求式响应时间记录
var respTime = {};


var numberType = ["en", "ex", "station_id_list_count", "weight"]
var areaArr = ["hz", "nb", "wz", "tz", "jh", "sx", "hu", "qz", "ls", "zs", "jx"];

function timeData () {
    var obj = {};
    //高速卡口查询消息
    obj.req = {
        "date": getNowFormatDate(0, "-")
    }
    obj.reqArea = { 
        "date": getNowFormatDate(0, "-"),
        "area": "wz"
    }
    obj.weightStation = {
        "date": getNowFormatDate(0, "-"),
        "station_id_list_count": 1,
        "station_id_list": [1001]
    }
    //铁路查询消息
    obj.tlTime = {
        "Station": "嘉善",
        "TrainDate": getNowFormatDate(0),
        "code": "ZJ01"
    }
    obj.tlLcsj = {
        "station": "杭州东",
        "traindate": getNowFormatDate(0, "-"),
        "traincode": "G594",
        "code": "ZJ01"
    }
    obj.tlsxk = {
        "TrainDate": getNowFormatDate(2),//////////////
        "TrainCode": "",
        "StationName": "杭州东",
        "code": "ZJ01"
    }
    obj.tlsxkys = {
        "TrainDate": getNowFormatDate(0),
        "TrainCode": "",
        "StationName": "杭州东",
        "code": "ZJ01"
    }
    return obj
}
//高速卡口查询消息
// var req = {
//     "date": getNowFormatDate(0, "-")
// }
// var reqArea = { 
//     "date": getNowFormatDate(0, "-"),
//     "area": "wz"
// }
// var weightStation = {
//     "date": getNowFormatDate(0, "-"),
//     "station_id_list_count": 1,
//     "station_id_list": [1001]
// }

//航空查询消息
var hlzhData = {
    "code": "HGH"
}

var hlwlhbskb = {
    "fnum": "CA1777"
}
var hljcll = {
    "airport": "HGH"
}
//铁路查询消息
var tlProvince = {
    "province": "浙江",
    "code": "ZJ01"
}
var tlName = {
    "station": "hz",
    "code": "ZJ01"
}
// var tlTime = {
//     "Station": "嘉善",
//     "TrainDate": getNowFormatDate(0),
//     "code": "ZJ01"
// }

var tlLcTime = {
    "train": "G7625",
    "code": "ZJ01"
}

// var tlLcsj = {
//     "station": "杭州东",
//     "traindate": getNowFormatDate(0, "-"),
//     "traincode": "",
//     "code": "ZJ01"
// }
var tlGet = {
    "code": "ZJ01"
}
// var tlsxk = {
//     "TrainDate": getNowFormatDate(2),//////////////
//     "TrainCode": "",
//     "StationName": "杭州东",
//     "code": "ZJ01"
// }
// var tlsxkys = {
//     "TrainDate": getNowFormatDate(0),
//     "TrainCode": "",
//     "StationName": "杭州东",
//     "code": "ZJ01"
// }

var manualData = {
    "date": "2017-08-28",
    "en": "1513612",
    "ex": "1516792",
}

var polymerList = {
    "left_top_lon": 119.9184,
    "left_top_lat": 30.33176,
    "right_bottom_lon": 120.29822,
    "right_bottom_lat": 30.25173,
    "min": 2,
    "max": 200,
    "delta": 0.02,
    "level": 9,
}

var sectionLast = {
    "station_name": "杭州东"
}

var tlkljjr = {
    "jnksrq": "2016-10-01",
    "qnksrq": "2015-10-01",
    "ts": 7
}

var lkywpolyer = {
    "left_top_lon": 119.9184,
    "left_top_lat": 30.33176,
    "right_bottom_lon": 120.29822,
    "right_bottom_lat": 30.25173,
    "min": 2,
    "max": 200,
    "delta": 0.02,
    "level": 9,
    "type": "033",
}

var taxipolymer = {
    "left_top_lon": 119.9184,
    "left_top_lat": 30.33176,
    "right_bottom_lon": 120.29822,
    "right_bottom_lat": 30.25173,
    "min": 2,
    "max": 200,
    "delta": 0.02,
    "level": 9,
    "status": 0,
}

var aispolymer = {
    "left_top_lon": 119.9184,
    "left_top_lat": 30.33176,
    "right_bottom_lon": 120.29822,
    "right_bottom_lat": 30.25173,
    "min": 2,
    "max": 200,
    "delta": 0.02,
    "level": 9,
}

var taxipolymenrizereq={
    "left_top":119.9184,
    "right_bottom":120.29822,
    "level":9,
    "min":2,
    "max":200,
    "delta":0.02,
    "status":0
}

var mapInfo = {
    "left_top_lon": 0,
    "left_top_lat": 90,
    "right_bottom_lon": 180,
    "right_bottom_lat": -90,
    "rteg_max": 5,
    "rteg_min": 2,
    "lonlat_type": 2,
    "show_name_null": 1,
    "scale": 2,
    "show_unknown": 1
}

var certificateData = {
    "info": {
        "ver": 2,
        "sn": "{51A90785-962A-420A-8C1F-3418ACF51176}",
        "user": "杭州皓天信息技术有限公司",
        "begin": "2018-12-28",
        "end": "2019-12-31",
        "area": "test",
        "ip": "",
        "idlist": "",
        "subscribe": "@*@",
        "notify": "@*@",
        "send": "*",
        "limit": 20,
        "localhost": false,
        "email": "langjm@hituns.com",
        "tel": "15757173290",
        "server_id": ""
    },
    "check": "d61b17a650b80340c773b0323f6e4d29"
}; //数字证书

var ajaxRespData = {};//ajax错误返回信息

function ajaxSend(url,data){
    var sendData = data ? data : null;
    $.ajax({
        url: url,
        type: "get",
        data: sendData,
        success: function(res){
            ajaxRespData.url = url;
            if(url.indexOf("gskk_stats_manual") ==-1 && !res){
                ajaxRespData.error = "无返回数据";
                postReq(ajaxRespData);
                console.log("无返回数据");
            }else if(!!res){
                var result = JSON.parse(res);
                if(JSON.stringify(result)[0] == "{"){
                    if( JSON.stringify(result) == {}){
                        ajaxRespData.error = "返回内容为空对象";
                        postReq(ajaxRespData);
                        console.log("返回内容为空对象");
                    }else if(parseCode[parseDecimal(result.result)]){
                        ajaxRespData.error = parseCode[parseDecimal(result.result)];
                        postReq(ajaxRespData);
                    }
                }else if(result instanceof Array){
                    if(result.length == 0){
                        ajaxRespData.error = "返回内容为空数组";
                        postReq(ajaxRespData);
                        console.log("返回内容为空数组");
                    }
                }
            }
        },
        error: function(res,status,xhr){
            ajaxRespData.url = url;
            if(xhr){
                ajaxRespData.error = xhr;
            }else{
                ajaxRespData.error = "pending";
            }
            postReq(ajaxRespData);
        }
    });
}

function subAjax(){
    ajaxSend("http://120.55.85.1:8066/cmb/gskk_stats_data")
    // ajaxSend("http://120.55.85.1:8066/cmb/gskk_stats_manual",manualData)
    ajaxSend("http://120.55.85.1:8066/cmb/gskk_llqs_data")
    ajaxSend("http://120.55.85.1:8066/cmb/zjqr_gsll_data")
    ajaxSend("http://120.55.85.1:8066/cmb/drgsll_sspm")
    ajaxSend("http://120.55.85.1:8066/cmb/gsxx_data")
    ajaxSend("http://120.55.85.1:8066/cmb/sjjckll")
    ajaxSend("http://120.55.85.1:8066/cmb/gsll_db")
    ajaxSend("http://120.55.85.1:8066/cmb/gsll_db_jjr",tlkljjr)
    ajaxSend("http://120.55.85.1:8066/cmb/gsll_stats_more")
    ajaxSend("http://120.55.85.1:8066/cmb/gstdhz")
    ajaxSend("http://120.55.85.1:8066/cmb/aircraft_list")
    setTimeout(function(){
        ajaxSend("http://120.55.85.1:8066/cmb/aircraft_polymerize_list",polymerList)
        ajaxSend("http://120.55.85.1:8066/cmb/ais_polymerize_list",aispolymer)
        ajaxSend("http://120.55.85.1:8066/cmb/airport_status_list")
        ajaxSend("http://120.55.85.1:8066/cmb/airport_last_7days")
        ajaxSend("http://120.55.85.1:8066/cmb/airport_db")
        ajaxSend("http://120.55.85.1:8066/cmb/airport_db_jjr",tlkljjr)
        ajaxSend("http://120.55.85.1:8066/cmb/tlkl_station_top")
        ajaxSend("http://120.55.85.1:8066/cmb/tlkl_sxk")
        ajaxSend("http://120.55.85.1:8066/cmb/tlkl_last_7days")
        ajaxSend("http://120.55.85.1:8066/cmb/tlkl_station_last_7days",sectionLast)
        ajaxSend("http://120.55.85.1:8066/cmb/tlkl_next_7days")
        ajaxSend("http://120.55.85.1:8066/cmb/tlkl_next_12hours")
        ajaxSend("http://120.55.85.1:8066/cmb/tlkl_db")
    },30000)
    setTimeout(function(){
        ajaxSend("http://120.55.85.1:8066/cmb/tlkl_db_jjr",tlkljjr)
        ajaxSend("http://120.55.85.1:8066/cmb/lkyw_online_total")
        ajaxSend("http://120.55.85.1:8066/cmb/lkyw_polymerize_list",lkywpolyer)
        ajaxSend("http://120.55.85.1:8066/cmb/taxi_list")
        ajaxSend("http://120.55.85.1:8066/cmb/taxi_polymerize_list",taxipolymer)
        ajaxSend("http://120.55.85.1:8066/cmb/get_jjr")
        // ajaxSend("http://120.55.85.1:8066/cmb/ais_list")//暂无数据
        ajaxSend("http://120.55.85.1:8066/cmb/ais_polymerize_list",aispolymer)
        ajaxSend("http://120.55.85.1:8066/cmb/map_tmc_info",mapInfo)
        ajaxSend("http://120.55.85.1:8066/cmb/map_tmc_status",mapInfo)
    },60000)
    setTimeout(function(){
        subAjax();
    },60 * 60 * 1000);
}

function logRender(data){//日志渲染
    for(var i=0; i<data.length; i++){
        var parseLog = logParse[data[i][1]]?logParse[data[i][1]]:data[i][1]
        var liStr = "<li><span>日志时间："+data[i][0]+"</span><span>日志类型："+parseLog+"</span><span>guid："+data[i][2]+"</span><span>日志描述："+data[i][3]+"</span></li>"
        $(".res-list").append(liStr);
    }
}

function postReq(data) { //小机器人报错请求
    var result = "";
    // var resInforData = "";
    var text = "";
    if(!data.url){
        CreateJson(data);        
    }

    if (!!data.info && !!data.info.result) {
        if (data.info.result.code != 0) {
            result = "#### 错误信息：" + parseCode[parseDecimal(data.info.result.code)];
        }
        if (data.info.result.code == 0 && data.info.data == undefined) {
            result = "#### 错误信息：无返回数据";
        }
    }
    if(data.type){
        text = "#### 数据查询请求类型：" + reqDataTypeName[data.type] + "(" + data.type.replace(
                            "resp", "req") + ")" + " \n" +
                        result + "\n" 
    }else if(data.cpuIp){
        text = "#### 错误内容：cpu占用过大" +"\n" +
                "#### 错误类型：" + data.cpuser +"\n" +
                "#### ip地址：" + data.cpuIp +"\n"
    }else if (data.noResp){
        result = "#### 错误信息：" + data.result;
        text = "#### 数据查询请求类型：" + reqDataTypeName[data.noResp] + " \n" +
                        result + "\n"
    }else {
        result = "#### 错误信息：" + data.error;
        text = "#### 数据查询请求类型：" + reqDataTypeName[data.url] + "(" + data.url + ")" + " \n" +
                        result + "\n"
    }
    var postData = JSON.stringify({
        "data": {
            "token": "https://oapi.dingtalk.com/robot/send?access_token=c357176a9bc1764119090d22c7e15c3dc15c88f93e481a056870a9ded92db774",
            // "token": "https://oapi.dingtalk.com/robot/send?access_token=e645ce7ef7f55dff76cde00f5b63716ab7e337619818eb951c319e48bf5fd669",
            "msg": {
                "msgtype": "markdown",
                "markdown": {
                    "title": "消息总线监控",
                    "text": text
                }
            }
        }
    });
    $.post("http://120.55.85.1:8069/intu/dingtalk_robot", postData);
}

function parseDecimal(code) { //转16进制
    var parsed = code.toString(16);
    var sixthParsed = "0x" + (new Array(5 - parsed.length).join('0') + parsed).toUpperCase();
    return sixthParsed;
}

$(".clear-message").on("click",function(){
    $(".res-list").html("");
});

function getNowFormatDate(num, seperator,boo) { //获取当前时间
    var date = new Date();
    var seperator = seperator ? "-" : "";
    var booHour = boo ? boo : false;
    var year = date.getFullYear();
    var month = date.getMonth() + 1;
    var strDate = date.getDate() - num;
    var hour = date.getHours();
    var minute = date.getMinutes() >=1 && date.getMinutes()<=9 ? "0" + date.getMinutes() : date.getMinutes();
    var second = date.getSeconds() >=1 && date.getSeconds()<=9 ? "0" + date.getSeconds() : date.getSeconds();
    if (month >= 1 && month <= 9) {
        month = "0" + month;
    }
    if (strDate > 0 && strDate <= 9) {
        strDate = "0" + strDate;
    }else if(strDate <=0){
        month = month - 1;
        if(month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12){
            strDate = 31 + strDate;
        }else if(month == 2){
            strDate = 29 + strDate;
        }else if(month == 0){
            strDate = 31;
            year = year - 1;
            month = 12;
        }else{
            strDate = 30 + strDate;
        }
        if(month >= 1 && month <= 9){
            month = "0" + month;
        }
    }
    if(!booHour){
        var currentdate =year + seperator + month + seperator + strDate
    }else{
        var currentdate =year + seperator + month + seperator + strDate + " " + hour + ':' + minute + ':' + second 
    }
    return currentdate;
}

function writeToScreen(message) { 
    var respMessage = document.getElementsByClassName('resp-mesBox')[0];
    var pre = document.createElement("p");
    pre.classList.add('resp-mes')
    pre.style.wordWrap = "break-word";
    pre.innerHTML = message;
    respMessage.appendChild(pre);
}


var funDownload = function (content, filename) {
    var eleLink = document.createElement('a');
    eleLink.download = filename;
    eleLink.style.display = 'none';
    var blob = new Blob([content]);
    eleLink.href = URL.createObjectURL(blob);
    document.body.appendChild(eleLink);
    eleLink.click();
    document.body.removeChild(eleLink);
};

function CreateJson(data){
    var result = "";
    if (!!data.info && !!data.info.result) {
        if (data.info.result.code != 0) {
            result = parseCode[parseDecimal(data.info.result.code)];
        }
        if (data.info.result.code == 0 && data.info.data == undefined) {
            result = "无返回数据";
        }
    }
    if(data.type){
        var errorData = {
            "errortime":getNowFormatDate(0,"_",true),
            "errorType":reqDataTypeName[data.type] + "(" + data.type.replace("resp", "req") + ")",
            "errorContent":result,
        }
    }else if(data.time){
        var errorData = {
            "errortime":getNowFormatDate(0,"_",true),
            "time":data.time,
            "cpuser":data.cpuser,
            "errorContent": data.cpuName + "cpu占用过大" + data.cpuOcc,
            "guid":data.guid
        }
    }else if(data.noResp){
        var errorData = {
            "errortime":getNowFormatDate(0,"_",true),
            "errorType":reqDataTypeName[data.noResp],
            "errorContent":data.result,
        }
    }else{
       var errorData = {
            "errortime":getNowFormatDate(0,"_",true),
            "errorType":reqDataTypeName[data.url] + "(" + data.url + ")",
            "errorContent":  data.error
        } 
    }
    errorData = JSON.stringify(errorData);
    $.post("http://116.62.174.108:80/error/write",errorData);
}